//
//  CarOwnerLeftMenuViewController.m
//  GoodWayClient
//
//  Created by HuiDong on 15/12/21.
//  Copyright © 2015年 HuiDong. All rights reserved.
//

#import "CarOwnerLeftMenuViewController.h"
#import "GoodsManagerViewController.h"
#import "AppDelegate.h"
#import "AccountTableViewController.h"
#import "ExperienceVoucherManagerTableViewController.h"
#import "CompanyTableViewController.h"
#import "IntegralAmountTableViewController.h"
#import "LeftMenuTopTableViewCell.h"
#import "CommendHistoryTableViewController.h"
#import "OwnerAccountTableViewController.h"
#import "OwnerBuyNotesViewController.h"
#include "OwnerIntegralViewController.h"

@interface CarOwnerLeftMenuViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)NSDictionary *dic;
@end

@implementation CarOwnerLeftMenuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    UIImageView *imageview = [[UIImageView alloc] initWithFrame:self.view.bounds];
    imageview.image = [UIImage imageNamed:@"bg.png"];
    [self.view addSubview:imageview];
    
    UITableView *tableview = [[UITableView alloc] init];
    self.tableview = tableview;
    tableview.frame = self.view.bounds;
    tableview.dataSource = self;
    tableview.delegate  = self;
    tableview.separatorStyle = UITableViewCellSeparatorStyleNone;

    tableview.rowHeight=50;
    [self.view addSubview:tableview];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//懒加载
- (NSDictionary *)dic
{
    if (!_dic) {
        _dic = @{@"head":@"logo",@"name":@"蓝天使者"};
    }
    return _dic;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *Identifier = @"Identifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Identifier];
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.font = [UIFont systemFontOfSize:20.0f];
    cell.backgroundColor = [UIColor clearColor];
    cell.textLabel.textColor = [UIColor whiteColor];
    
    if (indexPath.row == 0) {
        cell.textLabel.text = @"账户信息";
        cell.imageView.image = [UIImage imageNamed:@"logo"];
    } else if (indexPath.row == 1) {
        cell.textLabel.text = @"购买记录";
        cell.imageView.image = [UIImage imageNamed:@"logo"];
    }  else if (indexPath.row == 2) {
        cell.textLabel.text = @"积分/金额";
        cell.imageView.image = [UIImage imageNamed:@"logo"];
    } else if (indexPath.row == 3) {
        cell.textLabel.text = @"退出登录";
        cell.imageView.image = [UIImage imageNamed:@"logo"];
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    
    if (indexPath.row == 0) {
        //账户信息
        OwnerAccountTableViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"OwnerAccountTableViewController"];
        [tempAppDelegate.LeftSlideVC closeLeftView];//关闭左侧抽屉
        [tempAppDelegate.mainNavigationController pushViewController:vc animated:NO];
        
    }else if (indexPath.row == 1)
    {
        //购买记录
        OwnerBuyNotesViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"OwnerBuyNotesViewController"];
        [tempAppDelegate.LeftSlideVC closeLeftView];//关闭左侧抽屉
        [tempAppDelegate.mainNavigationController pushViewController:vc animated:NO];
    }else if (indexPath.row == 2)
    {
        //积分/金额
        OwnerIntegralViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"OwnerIntegralViewController"];
        [tempAppDelegate.LeftSlideVC closeLeftView];//关闭左侧抽屉
        [tempAppDelegate.mainNavigationController pushViewController:vc animated:NO];
        
    }else
    {
        [self.delegate clear];
        //退出登录
        [tempAppDelegate.LeftSlideVC back];
        
    }
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 180;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    LeftMenuTopTableViewCell *cell = [LeftMenuTopTableViewCell LeftMenuTopWithTableView:tableView];
    cell.backgroundColor = [UIColor clearColor];
    cell.dic = self.dic;
    return cell;
}


@end
